package sn.ugb.cours.zd.ejb.entity;

import static sn.ugb.cours.zd.ejb.entity.Personne.QN.ALL_PERSON;
import static sn.ugb.cours.zd.ejb.entity.Personne.QN.FIND_PERSON;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * Une personne.
 * @author zakaria
 */
@Entity
@Table(name="UTILISATEURS")
@NamedQueries({@NamedQuery(name=ALL_PERSON, query="select o FROM Personne o"),
               @NamedQuery(name=FIND_PERSON, query="select o FROM Personne o WHERE o.nom = :MYNAME")})
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class Personne implements Serializable {
    /**
     * Requetes nommees.
     */
    public static interface QN {
        String ALL_PERSON = "person.allPersonnes";
        String FIND_PERSON = "person.findPersonne";
    }

    /**
     * Serial Version UID.
     */
    private static final long serialVersionUID = 0L;


	/**
     * Primary key
     */
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="ID")
    private long id;

    /**
     * nom de la personne.
     */
    private String nom = null;
   
    /**
     * prenom de la personne.
     */
    private String prenom = null;
    

	/**
     * mail de la personne.
     */
    private String mail = null;
    
    public Personne() {
    }

    /**
     * Constructor with a given author name.
     * @param nom - the name of the author
     */
    public Personne(final String nom) {
        setNom(nom);
    }

    
    /**
	 * @param nom
	 * @param prenom
	 * @param mail
	 */
	public Personne(String nom, String prenom, String mail) {
		this.nom = nom;
		this.prenom = prenom;
		this.mail = mail;
	}

    /**
     * @return name of the author
     */
    public String getNom() {
        return nom;
    }

    /**
     * Sets the name of the author.
     * @param nom - the name of this author
     */
    public void setNom(final String nom) {
        this.nom = nom;
    }

    /**
     * @return an id for this object (incremented automatically)
     */
    public long getId() {
        return this.id;
    }

    /**
     * Sets the id of this person object.
     * @param id the given id of this person
     */
    public void setId(final long id) {
        this.id = id;
    }


    public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}


	/**
     * @return String representation of this entity object.
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder(this.getClass().getName());
        sb.append("[id=");
        sb.append(getId());
        sb.append(", name=");
        sb.append(getNom());
        sb.append("]");
        return sb.toString();
    }
}
